package com.bill.common.utils;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Verification {
	
	public final static String  MD5 = "a"; 
	public final static String  SHA = "b"; 
	public final static String  SSHA = "c"; 
	public String getMD5Str(String str) {  
        MessageDigest messageDigest = null;  
  
        try {  
            messageDigest = MessageDigest.getInstance("MD5");  
            messageDigest.reset();  
            messageDigest.update(str.getBytes("UTF-8"));  
        } catch (NoSuchAlgorithmException e) {  
            System.exit(-1);  
        } catch (UnsupportedEncodingException e) {  
            e.printStackTrace();  
        }  
        byte[] byteArray = messageDigest.digest();  
  
        StringBuffer md5StrBuff = new StringBuffer();  
  
        for (int i = 0; i < byteArray.length; i++) {              
            if (Integer.toHexString(0xFF & byteArray[i]).length() == 1)  
                md5StrBuff.append("0").append(Integer.toHexString(0xFF & byteArray[i]));  
            else  
                md5StrBuff.append(Integer.toHexString(0xFF & byteArray[i]));  
        }  
        return md5StrBuff.toString();  
    }
	
	public String test(String str,String type){
		return type+"-"+str+"-N";
	}
	
	public String ver1(String value,String type){
		String test = test(value,type);
		return getMD5Str(test);
	}
	public boolean vs(String key1,String key2,String key3,String value,Long id){
//		if((key1==null && key2==null && key3==null ) || (key1.equals(ver1(value.toString()+id, Verification.MD5)) && 
//				key2.equals(ver1(value.toString()+id, Verification.SHA)) &&
//				key3.equals(ver1(value.toString()+id, Verification.SSHA)))
//				){
//			return true;
//		}else{
//			System.out.println("有异常了::::::::::::::::::::::");
//			ApplicationContext ac = AppliactionScheduledListener.ctx;
//			IEmailService emailService = (IEmailService)ac.getBean("emailService");
//			IAccountDAO accountDAO = (IAccountDAO)ac.getBean("accountDAO");
//			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//			//发送邮件
//			String title = "账户ID为::"+id+"的有异常，请检查!";
//			String content = sdf.format(new Date())+"账户ID为::"+id+"的系统检查出有异常，请检查!现在的提现钱包是:"+value;
//			emailService.sendMail("1951203385@qq.com", title, content);
//			Account acs = accountDAO.findById(id);
//			if(acs!=null){
//				acs.setAcId(acs.getAccountId()+1);
//				accountDAO.merge(acs);
//			}
//				
//			
//			return false;
//		}
		
		return false;
			
	}
	
}
